# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Balló György <ballogyor+arch at gmail dot com>

_name=minidb
pkgname=python-minidb
pkgver=2.0.7
pkgrel=2
pkgdesc='Simple SQLite3 store for Python objects'
arch=('any')
url=https://thp.io/2010/minidb/
license=('ISC')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools'
             'python-wheel')
checkdepends=('python-pytest')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz")
sha256sums=('339fd231e3b34daecd3160946e0141585666ac57583882a14c4c69e597accca1')
b2sums=('349aff4ec7497fc74edd632f719a6f67a2e7c1dff38ea1ea579c820e00dbad4e7269355e4b19ccfe53cf637f0ebdd6cd512e1af84456ef70c05d8e19024ae94d')

build() {
  cd $_name-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd $_name-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -d "$pkgdir"/usr/share/licenses/$pkgname
  sed -n '/# Copyright/,/OF THIS SOFTWARE./p' minidb.py > "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
